﻿using System;
using System.Web.UI;
using BLL;
using Web.Class;

namespace Web.Pages.YongShui._15.BaoBiaoGL.DanJuDY
{
    public partial class LaiHanDZDY : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txtDate1.Text = DateTime.Now.ToString("yyyyMMdd");
                txtDate2.Text = DateTime.Now.ToString("yyyyMMdd");
            }
        }

        protected void btnChaXun_OnClick(object sender, EventArgs e)
        {
            if (txtDate2.Text != "" && txtDate1.Text == "")
            {
                PageTools.AlertMsg(this,"输入审批日期的开始时间");
                return;
            }
            string startDate = txtDate1.Text.Substring(0, 4) + "-" + txtDate1.Text.Substring(4, 2) + "-" +
                               txtDate1.Text.Substring(6, 2);
            string endDate = txtDate2.Text.Substring(0, 4) + "-" + txtDate2.Text.Substring(4, 2) + "-" +
                               txtDate2.Text.Substring(6, 2);
            var result = new SqlHelper().GetLaiHanUser(cmbLaiHanType.SelectedItem.Value.ToString(), startDate,
                endDate);
            gridLaiHanUser.DataSource = result.Tables[0];
            gridLaiHanUser.DataBind();
            if (result.Tables[0] != null && result.Tables[0].Rows.Count > 0)
            {
                zjl.Text = "共" + result.Tables[0].Rows.Count + "条";
                var yonghuh = result.Tables[0].Rows[0]["S_YONGHUH"].ToString();
                txtYHH1.Text = yonghuh;
                txtYHH2.Text = yonghuh;
            }
        }
    }
}